﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections.ObjectModel;
using RiskMan.DataClass;
using RiskMan.DataClass.Gerchik;

namespace RiskMan.Config
{
    public class History
    {
        private Data _data;

        #region Загрузка

        public History(DataClass.Data _dataProvider)
        {
            this._data = _dataProvider;
        }

        public void Load()
        {
            _data.GechikRobotItemList = GetGerchikRobot();
        }

        private ObservableCollection<GechikRobotItem> GetGerchikRobot()
        {
            return (ObservableCollection<GechikRobotItem>)XmlHistory.GetXmlData(XmlHistory.FILENAME_GerchikRobots);
        }

        #endregion

        #region Сохранение

        public void Save()
        {
            SetGerchikRobot(_data.GechikRobotItemList);
        }

        private void SetGerchikRobot(ObservableCollection<GechikRobotItem> observableCollection)
        {
            XmlHistory.SetXmlData(XmlHistory.FILENAME_GerchikRobots, (Object)(observableCollection.ToList()));
        }

        #endregion
    }
}